#ifndef SHOW_HPP_INCLUDED
#define SHOW_HPP_INCLUDED

#include "Process/observer.hpp"
#include "Process/process.hpp"

#include "Frame/states.hpp"

#include <fstream>
#include "image.h"
#include <string>
#include <vector>
#include <iostream>
#include <math.h>

using namespace std;

class Point
{
public:
	Point(){x=0;y=0;};
	Point(float _x, float _y):x(_x),y(_y){};
	~Point(){};
	float x, y;
};

class Trajectory
{
public:
	Trajectory();
	Trajectory(string src){load(src);}
	~Trajectory(){};
	void load(string src);
	void init();
	void smooth(int n);
	
	vector<Point> location;
	
	vector<Point> v;
	vector<Point> a;
};

class Person
{
public:
	Person();
	~Person(){};
	void load(string src);
	void smooth(int n);
	void GetTP();
	double ComputAccTpt(int ts, int te);
	
	Trajectory head,hand_l,hand_r;
	vector<Point> headpose;
	vector<float> _headpose;
	
	vector<float> Acc;
	vector<int> Att;
	vector<Point> TP;

	static float Threshold_TP;
private:
	
};

class Influence
{
public:
	double SI, TI;
	int PF, PT;
	
	double MI(){return SI>TI?SI:TI;} // Max( SpatialInfluence, TemporalInfluence)
	void SetInfluence( double spatialinfluence, double temporalinfluence, int personfrom, int personto)
	{
		SI = spatialinfluence;
		TI = temporalinfluence;
		PF = personfrom;
		PT = personto;
	}	
};

class TrajectoryInfluence
{
public:
	Influence Average; //average influence for all transition points of a trajectory (person j -> i)
	vector< Influence > TrajInfluence; // all influence of a trajectory (person j -> i )
};

class  Show:public Observer
{
public:
	Show(Process *pro, States *_state);
	~Show();
	 
	void Update(const Image &image);
	void GetAtt();
	void GetInfluence(int ts, int te);
	int GetDeltaT(int personto, int personfrom, int timet);
	
	Image out;
protected:
private:
	States *state;

	std::ofstream outFile;

	float sigma_1, sigma_2, sigma_3, ssigma;
	float Alpha, Beta, Gama;
	
	int t_count;
	
	int num;
	Person p[3];
	vector<vector<TrajectoryInfluence> > AllInfluence;	
};

#endif // SHOW_HPP_INCLUDED
